![]() |
PBLockRangeSync |
||||
Header: | Files.h | Carbon status: | Supported | |
Locks a portion of a file.
OSErr PBLockRangeSync ( ParmBlkPtr paramBlock );
A pointer to a basic File Manager parameter block.
A result code.
The relevant fields of the parameter block are:
On input, a pointer to a completion function.
On output, the result code of the function.
On input, the file reference number
On input, the number of bytes in the range.
On input, the positioning mode.
On input, the positioning offset.
The PBLockRangeSync function locks a portion of a file that was opened with shared read/write permission. The beginning of the range to be locked is determined by the ioPosMode and ioPosOffset fields. The end of the range to be locked is determined by the beginning of the range and the ioReqCount field. For example, to lock the first 50 bytes in a file, set ioReqCount to 50, ioPosMode to fsFromStart, and ioPosOffset to 0. Set ioReqCount to –1 to lock the maximum number of bytes from the position specified in ioPosOffset.
The PBLockRangeSync function uses the same parameters as both PBReadSync and PBWriteSync; by calling it immediately before PBRead, you can use the information in the parameter block for the PBRead call.
When you’re finished with the data (typically after a call to PBWriteSync), be sure to call PBUnlockRangeSync to free that portion of the file for subsequent PBReadSync calls.
The PBLockRangeSync function does nothing if the file specified in the ioRefNum field is open with shared read/write permission but is not located on a remote server volume or is not located under a share point on a sharable local volume.
In system software versions 6.0.7 and earlier, specifying ioPosMode as fsFromLEOF results in the wrong byte range being locked.
Supported in Carbon. Available in Mac OS 8.1 and later when Carbon 1.0.2 or later is present.
© 2000 Apple Computer, Inc. — (Last Updated 5/8/2000)